<template>
	<view class="position-flex-bottom box-shadow-g" style="z-index: 999;">
		<uni-goods-nav
			:fill="true" 
			:options="options" 
			:buttonGroup="buttonGroup" 
			@keftEvent="ClickEvent"
			@buttonClick.stop="buttonClick" />
	</view>
</template>

<script>
	/**
	 * 底部导航
	 * */ 
	import uniGoodsNav from '@/components/uni_modules/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		name: 'x-goods-nav',
		components:{
			uniGoodsNav
		},
		props: {
			info:{
				type:[String,Number],
				default:0
			},
			goodsType:{
				type:[String,Number]
			},
			activity_id:{
				type:[String,Number],
				default:0
			}
		},
		watch:{
			info(e){
				this.options[1].info=e
				console.log(e);
			},
			goodsType:{
				immediate: true,
				handler(){
					if(this.goodsType==0){
						this.buttonGroup= [
							{
								text: '加入购物车',
								backgroundColor: '#ddd',
								color: '#fff',
								type:0
							},
							{
								text: '立即购买',
								backgroundColor: '#FF890B',
								color: '#fff',
								type:1
							}
						]
						return
					}
					if(this.goodsType==1){
						if(this.activity_id){
							this.buttonGroup=[
								{
									text: '发起拼团',
									backgroundColor: '#ddd',
									color: '#fff',
									type:1
								},
								{
									text: '加入团购',
									backgroundColor: '#FF890B',
									color: '#fff',
									type:1,
									activity_id:this.activity_id
								}
							]
						}else{
							this.buttonGroup=[
								{
									text: '发起拼团',
									backgroundColor: '#FF890B',
									color: '#fff',
									type:1
								}
							]
						}
					}
					if(this.goodsType==2){
						this.buttonGroup=[
							{
								text: '立即秒杀',
								backgroundColor: '#FF890B',
								color: '#fff',
								type:1
							}
						]
					}
					
				}
			}
		},
		data(){
			return {
				options: [
					{
						icon: '/static/icon/lenv.png',
						text: '帮助中心',
					}, {
						icon: '/static/icon/gouwuche.png',
						info: 0,
						infoBackgroundColor: '#FF4830',
						text: '购物车',
					},
				],
				buttonGroup: []
			}
		},
		methods: {
			// 底部菜单，左边选择
			ClickEvent(e){
				console.log('left',e);
				if(e.index==0){
					uni.navigateTo({ // 帮助中心
						url:'/goodsPackage/help/help'
					})
				}else{
					uni.switchTab({ // 购物车
						url:'/pages/Shopping-Cart/Shopping-Cart'
					})
				}
				this.$emit('leftEvent',e)
			},
			// 底部菜单，右边。加入购物车/立即购买
			buttonClick(e){
				this.$emit('rightEvent',e)
			},
		}
	}
</script>

<style lang="scss">
	
</style>
